Каждая хорошо спроектированная консольная утилита должна принимать аргументы в виде опций (например, -h или --help), опций с параметрами (--log-level 2) или позиционных параметров (cp file1 file2).
Опции отличаются от позиционных параметров тем, что начинаются с одного или двух дефисов. Проблемы возникают, когда позиционные аргументы тоже начинаются с дефиса — например, если нужно удалить файл с именем -rf: команда rm -rf в таком случае не работает как ожидается.
Общепринятый способ решения этой проблемы — поддержка разделителя --. Аргументы, идущие после --, никогда не интерпретируются как опции:
$ echo test > -rf $ cat -rf cat: invalid option -- 'r' Try 'cat --help' for more information. $ cat -- -rf test $ rm -- -rf $ cat -- -rf cat: -rf: No such file or directory
Модуль argparse автоматически обрабатывает -- за тебя.
Каждая хорошо спроектированная консольная утилита должна принимать аргументы в виде опций (например, -h или --help), опций с параметрами (--log-level 2) или позиционных параметров (cp file1 file2).
Опции отличаются от позиционных параметров тем, что начинаются с одного или двух дефисов. Проблемы возникают, когда позиционные аргументы тоже начинаются с дефиса — например, если нужно удалить файл с именем -rf: команда rm -rf в таком случае не работает как ожидается.
Общепринятый способ решения этой проблемы — поддержка разделителя --. Аргументы, идущие после --, никогда не интерпретируются как опции:
$ echo test > -rf $ cat -rf cat: invalid option -- 'r' Try 'cat --help' for more information. $ cat -- -rf test $ rm -- -rf $ cat -- -rf cat: -rf: No such file or directory
Модуль argparse автоматически обрабатывает -- за тебя.
The cloud-based messaging platform is also adding Anonymous Group Admins feature. As per Telegram, this feature is being introduced for safer protests. As per the Telegram blog post, users can “Toggle Remain Anonymous in Admin rights to enable Batman mode. The anonymized admin will be hidden in the list of group members, and their messages in the chat will be signed with the group name, similar to channel posts.”
That strategy is the acquisition of a value-priced company by a growth company. Using the growth company's higher-priced stock for the acquisition can produce outsized revenue and earnings growth. Even better is the use of cash, particularly in a growth period when financial aggressiveness is accepted and even positively viewed.he key public rationale behind this strategy is synergy - the 1+1=3 view. In many cases, synergy does occur and is valuable. However, in other cases, particularly as the strategy gains popularity, it doesn't. Joining two different organizations, workforces and cultures is a challenge. Simply putting two separate organizations together necessarily creates disruptions and conflicts that can undermine both operations.
Библиотека Python разработчика | Книги по питону from ca